package com.pro.controller;

import com.pro.common.GuavaCommon;
import com.pro.pojo.JsGoodsCount;
import com.pro.pojo.JsProductCategroy;
import com.pro.pojo.JsonData;
import com.pro.service.JsCourseCategroyService;
import com.pro.service.JsProductCategroyService;
import com.pro.utils.GuavaUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author  cyj
 * 课程树
 */
@RestController
@RequestMapping("/courseTree")
public class JsCourseCategroyController {

    @Autowired
    private JsCourseCategroyService service;
    //获取数据
    @RequestMapping("/getTree")
    public JsonData getTree(){
        List<JsProductCategroy> list = service.getTree();
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务端错误");
    }

    //添加类型
    @RequestMapping("/addCourseClass")
    public JsonData addCourseClass(JsProductCategroy JsProductCategroy){
        Boolean flag=service.addCourseClass(JsProductCategroy);

        return flag!=false?JsonData.buildSuccess(flag):JsonData.buildError("服务端错误");
    }

    //删除类型
    @RequestMapping("/delCourseClass")
    public JsonData delCourseClass(Integer categroyId){
        Boolean flag=service.delCourseClass(categroyId);
        return flag!=false?JsonData.buildSuccess(flag):JsonData.buildError("服务端错误");
    }

    //更新一个节点
    @RequestMapping("/updateCourseClass")
    public JsonData updateCourseClass(JsProductCategroy JsProductCategroy){
        Boolean flag=service.updateCourseClass(JsProductCategroy);
        return flag!=false?JsonData.buildSuccess(flag):JsonData.buildError("服务端错误");
    }
    //课程类型对应的点赞量
    @RequestMapping("/likeSum")
    public JsonData likeSum(){
        List<JsGoodsCount> list = service.likeSum();
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务端错误");
    }
    //课程类型对应的收藏量
    @RequestMapping("/collectionCount")
    public JsonData collectionCount(){
        List<JsGoodsCount> list = service.collectionCount();
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务端错误");
    }
    //课程类型对应的分享量
    @RequestMapping("/shareSum")
    public JsonData shareSum(){
        List<JsGoodsCount> list = service.shareSum();
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务端错误");
    }
    //课程类型对应的预览量
    @RequestMapping("/lookSum")
    public JsonData lookSum(){
        List<JsGoodsCount> list = service.lookSum();
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务端错误");
    }
    //课程类型对应的评论量
    @RequestMapping("/commentSum")
    public JsonData commentSum(){
        List<JsGoodsCount> list = service.commentSum();
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务端错误");
    }

}
